/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.unipampa.view;

import br.unipampa.utilitarios.ExecutaSom;
import br.unipampa.utilitarios.TrataAlarme;
import javax.swing.JFrame;

/**
 *
 * @author gabrielbmoro
 */
public class FrameAlarme extends javax.swing.JFrame implements EfeitosSonoros{

    private TrataAlarme trata;
    private ExecutaSom executaSom;
    /**
     * Creates new form FrameAlarme
     */
    public FrameAlarme() {
        initComponents();
        this.trata= TrataAlarme.getInstance();
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        setResizable(false);
        this.executaSom= new ExecutaSom();
        efeitoSonoro();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblImage = new javax.swing.JLabel();
        btnOk = new javax.swing.JButton();
        lblCompromisso = new javax.swing.JLabel();
        lblHorarioEData = new javax.swing.JLabel();
        lblAlarme = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Alarme");

        lblImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/unipampa/icons/relogioImg.png"))); // NOI18N

        btnOk.setText("Ok");
        btnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkActionPerformed(evt);
            }
        });

        lblCompromisso.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        lblCompromisso.setText("lblCompromisso");

        lblHorarioEData.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N
        lblHorarioEData.setText("lblHorarioEData");

        lblAlarme.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
        lblAlarme.setText("Alarme");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblImage)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblCompromisso)
                    .addComponent(lblHorarioEData)
                    .addComponent(lblAlarme))
                .addContainerGap(229, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblAlarme)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblHorarioEData)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblCompromisso))
                    .addComponent(lblImage))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addComponent(btnOk)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
        cancelaAlarme();
    }//GEN-LAST:event_btnOkActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnOk;
    private javax.swing.JLabel lblAlarme;
    private javax.swing.JLabel lblCompromisso;
    private javax.swing.JLabel lblHorarioEData;
    private javax.swing.JLabel lblImage;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the lblCompromisso
     */
    public javax.swing.JLabel getLblCompromisso() {
        return lblCompromisso;
    }

    /**
     * @param lblCompromisso the lblCompromisso to set
     */
    public void setLblCompromisso(javax.swing.JLabel lblCompromisso) {
        this.lblCompromisso = lblCompromisso;
    }

    /**
     * @return the lblHorarioEData
     */
    public javax.swing.JLabel getLblHorarioEData() {
        return lblHorarioEData;
    }

    /**
     * @param lblHorarioEData the lblHorarioEData to set
     */
    public void setLblHorarioEData(javax.swing.JLabel lblHorarioEData) {
        this.lblHorarioEData = lblHorarioEData;
    }
    private void cancelaAlarme(){
        this.trata.BOOL= false;
        pararEfeitoSonoro();
        this.dispose();
    }

    @Override
    public void efeitoSonoro() {
        this.executaSom.executarAlarme();
    }
    
    private void pararEfeitoSonoro(){
        this.executaSom.pararAlarme();
    }
}
